function calculate() {
    var num1 = document.getElementById("num1").value;
    console.log(typeof num1);
    num1 = parseInt(num1);
    var num2 = parseInt(document.getElementById("num2").value);
    var operation = document.getElementById("operation").value;
    var result = 0;

    switch (operation) {
        case 'add':
            result = num1 + num2;
            break
        case 'subtract':
            result = num1 - num2;
            break
        case 'multiply':
            result = num1 * num2;
            break
        case 'divide':
            if (num2 == 0) {
                alert("被除数不能为0")
                return;
            }
            result = num1 / num2;
            break
        default:
            alert("无效的运算符")
            result;
    }

    document.getElementById("result").innerText = result;
}